#include <iostream>
#include <UnidirectionLinkedList.hpp>

using namespace std;

class Solution
{
public:
    ListNode *removeNthFromEnd(ListNode *head, int n)
    {
        ListNode *dummy = new ListNode(0, head);
        ListNode *slow = dummy, *fast = dummy;
        int len = 0;
        while (fast != nullptr)
        {
            fast = fast->next;
            len++;
            if (len > n + 1)
            {
                slow = slow->next;
            }
        }
        slow->next = slow->next->next;
        return dummy->next;
    }
};

int main()
{
    cout << "Code19" << endl;
    Solution s;
    return 0;
}